package com.example.java_chatroom.demo;

// 泛型使用
class MyArray<T> {
    public T[] array = (T[]) new Object[10];

    public T getPos(int pos) {
        return this.array[pos];
    }

    public void setPos(int pos, T val) {
        this.array[pos] = val;
    }
}
public class Demo01 {
    public static void main(String[] args) {
//        MyArray<Integer> myArray = new MyArray<>();
        MyArray<Integer> myArray = new MyArray<Integer>();
        myArray.setPos(0, 10);
        myArray.setPos(1, 20);
        int ret = myArray.getPos(0);
        System.out.println("ret:"+ret);

    }
}
